

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  <meta name="description" content="平时用到的一些代码片段介绍新年快乐🐯 🎆这里介绍的是平常可能会用到的一些代码片段，可能对各位有点帮助，文章会持续更新✿✿ヽ(°▽°)ノ✿   正文Modal antd    内部控制visible   外部控制是否可关闭    typescript12345678910111213141516171819202122232425262728293031323334353637383940414">
<meta property="og:type" content="article">
<meta property="og:title" content="平时用到的一些代码片段">
<meta property="og:url" content="http://yoursite.com/2022/02/09/%E5%B9%B3%E6%97%B6%E7%94%A8%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E4%BB%A3%E7%A0%81%E7%89%87%E6%AE%B5/index.html">
<meta property="og:site_name" content="Food-Billboard">
<meta property="og:description" content="平时用到的一些代码片段介绍新年快乐🐯 🎆这里介绍的是平常可能会用到的一些代码片段，可能对各位有点帮助，文章会持续更新✿✿ヽ(°▽°)ノ✿   正文Modal antd    内部控制visible   外部控制是否可关闭    typescript12345678910111213141516171819202122232425262728293031323334353637383940414">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-02-09T07:19:00.000Z">
<meta property="article:modified_time" content="2022-09-02T07:18:35.000Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="fragment code">
<meta name="twitter:card" content="summary_large_image">
  
  <title>平时用到的一些代码片段 - Food-Billboard</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","version":"1.8.12","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname"}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<!-- hexo injector head_end start -->
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/bynotes/texiao/source/css/toubudaziji.css"></link>
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/bynotes/texiao/source/css/shubiao.css"></link>
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/project">
                <i class="iconfont icon-books"></i>
                项目
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/images/%E5%B9%B3%E6%97%B6%E7%94%A8%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E4%BB%A3%E7%A0%81%E7%89%87%E6%AE%B5/background.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="平时用到的一些代码片段">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2022-02-09 15:19" pubdate>
        2022年2月9日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      7.4k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      23 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">平时用到的一些代码片段</h1>
            
            <div class="markdown-body">
              <h2 id="平时用到的一些代码片段"><a href="#平时用到的一些代码片段" class="headerlink" title="平时用到的一些代码片段"></a>平时用到的一些代码片段</h2><h2 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h2><p>新年快乐🐯 🎆<br>这里介绍的是平常可能会用到的一些代码片段，可能对各位有点帮助，文章会持续更新✿✿ヽ(°▽°)ノ✿  </p>
<h2 id="正文"><a href="#正文" class="headerlink" title="正文"></a>正文</h2><h3 id="Modal"><a href="#Modal" class="headerlink" title="Modal"></a>Modal</h3><ul>
<li><a target="_blank" rel="noopener" href="https://ant.design/index-cn">antd</a>   </li>
<li>内部控制<code>visible</code>  </li>
<li>外部控制是否可关闭  </li>
</ul>
<h4 id="typescript"><a href="#typescript" class="headerlink" title="typescript"></a>typescript</h4><figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br></pre></td><td class="code"><pre><code class="hljs ts"><span class="hljs-keyword">import</span> React, &#123; forwardRef, useImperativeHandle, useRef, useCallback, useState &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;react&#x27;</span><br><span class="hljs-keyword">import</span> &#123; Modal, Button &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;antd&#x27;</span><br><span class="hljs-keyword">import</span> &#123; ModalProps &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;antd/es/modal&#x27;</span><br><br><span class="hljs-keyword">type</span> TModalRef = &#123;<br>  <span class="hljs-attr">open</span>: <span class="hljs-function">(<span class="hljs-params">value?: <span class="hljs-built_in">any</span></span>) =&gt;</span> <span class="hljs-built_in">void</span> <br>&#125;<br><br><span class="hljs-keyword">type</span> TModalProps = &#123;<br>  <span class="hljs-comment">// any props </span><br>&#125; &amp; Partial&lt;ModalProps&gt;<br><br><span class="hljs-comment">// modal </span><br><span class="hljs-keyword">const</span> InternalVisibleModal = forwardRef&lt;TModalRef, TModalProps&gt;(<span class="hljs-function">(<span class="hljs-params">props, ref</span>) =&gt;</span> &#123;<br><br>  <span class="hljs-keyword">const</span> &#123;  <br>    <span class="hljs-attr">onCancel</span>: propsOnCancel,<br>    <span class="hljs-attr">onOk</span>: propsOnOk<br>  &#125; = props <br><br>  <span class="hljs-keyword">const</span> [ visible, setVisible ] = useState&lt;<span class="hljs-built_in">boolean</span>&gt;(<span class="hljs-literal">false</span>)<br><br>  <span class="hljs-keyword">const</span> open = useCallback(<span class="hljs-function">(<span class="hljs-params">value?: <span class="hljs-built_in">any</span></span>) =&gt;</span> &#123;<br>    <span class="hljs-built_in">console</span>.log(value)<br>    setVisible(<span class="hljs-literal">true</span>)<br>  &#125;, [])<br><br>  <span class="hljs-keyword">const</span> onCancel = useCallback(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> result = propsOnCancel?.(e)<br>    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> result !== <span class="hljs-string">&#x27;boolean&#x27;</span> || result) &#123;<br>      setVisible(<span class="hljs-literal">false</span>)<br>    &#125;<br>  &#125;, [propsOnCancel])<br><br>  <span class="hljs-keyword">const</span> onOk = useCallback(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> result = propsOnOk?.(e)<br>    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> result !== <span class="hljs-string">&#x27;boolean&#x27;</span> || result) &#123;<br>      setVisible(<span class="hljs-literal">false</span>)<br>    &#125;<br>  &#125;, [propsOnOk])<br><br>  useImperativeHandle(ref, <span class="hljs-function">() =&gt;</span> &#123;<br>    <span class="hljs-keyword">return</span> &#123;<br>      open<br>    &#125;<br>  &#125;, [open])<br><br>  <span class="hljs-keyword">return</span> (<br>    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Modal</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">visible</span>=<span class="hljs-string">&#123;visible&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">onCancel</span>=<span class="hljs-string">&#123;onCancel&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">onOk</span>=<span class="hljs-string">&#123;onOk&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">title</span>=<span class="hljs-string">&#x27;自定义modal&#x27;</span></span></span><br><span class="hljs-tag"><span class="xml">    &gt;</span></span><br><span class="xml">      hello world </span><br><span class="xml">    <span class="hljs-tag">&lt;/<span class="hljs-name">Modal</span>&gt;</span></span><br>  )<br><br>&#125;)<br><br><span class="hljs-comment">// parent </span><br><span class="hljs-keyword">const</span> ParentComponent = <span class="hljs-function">() =&gt;</span> &#123;<br><br>  <span class="hljs-keyword">const</span> modalRef = useRef&lt;TModalRef&gt;(<span class="hljs-literal">null</span>)<br><br>  <span class="hljs-keyword">return</span> (<br>    <span class="xml"><span class="hljs-tag">&lt;&gt;</span></span><br><span class="xml">      <span class="hljs-tag">&lt;<span class="hljs-name">Button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">&#123;()</span> =&gt;</span> &#123;</span><br><span class="xml">        modalRef.current?.open()</span><br><span class="xml">      &#125;&#125;&gt;open<span class="hljs-tag">&lt;/<span class="hljs-name">Button</span>&gt;</span></span><br><span class="xml">      <span class="hljs-tag">&lt;<span class="hljs-name">InternalVisibleModal</span></span></span><br><span class="hljs-tag"><span class="xml">        <span class="hljs-attr">ref</span>=<span class="hljs-string">&#123;modalRef&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      /&gt;</span></span><br><span class="xml">    <span class="hljs-tag">&lt;/&gt;</span></span><br>  )<br><br>&#125;<br><br><br></code></pre></td></tr></table></figure>
<h4 id="javascript"><a href="#javascript" class="headerlink" title="javascript"></a>javascript</h4><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><code class="hljs jsx"><span class="hljs-keyword">import</span> React, &#123; forwardRef, useImperativeHandle, useRef, useCallback, useState &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;react&#x27;</span><br><span class="hljs-keyword">import</span> &#123; Modal, Button &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;antd&#x27;</span><br><br><span class="hljs-comment">// modal </span><br><span class="hljs-keyword">const</span> InternalVisibleModal = forwardRef(<span class="hljs-function">(<span class="hljs-params">props, ref</span>) =&gt;</span> &#123;<br><br>  <span class="hljs-keyword">const</span> &#123;  <br>    <span class="hljs-attr">onCancel</span>: propsOnCancel,<br>    <span class="hljs-attr">onOk</span>: propsOnOk<br>  &#125; = props <br><br>  <span class="hljs-keyword">const</span> [ visible, setVisible ] = useState(<span class="hljs-literal">false</span>)<br><br>  <span class="hljs-keyword">const</span> open = useCallback(<span class="hljs-function">(<span class="hljs-params">value</span>) =&gt;</span> &#123;<br>    <span class="hljs-built_in">console</span>.log(value)<br>    setVisible(<span class="hljs-literal">true</span>)<br>  &#125;, [])<br><br>  <span class="hljs-keyword">const</span> onCancel = useCallback(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> result = propsOnCancel?.(e)<br>    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> result !== <span class="hljs-string">&#x27;boolean&#x27;</span> || result) &#123;<br>      setVisible(<span class="hljs-literal">false</span>)<br>    &#125;<br>  &#125;, [propsOnCancel])<br><br>  <span class="hljs-keyword">const</span> onOk = useCallback(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> result = propsOnOk?.(e)<br>    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> result !== <span class="hljs-string">&#x27;boolean&#x27;</span> || result) &#123;<br>      setVisible(<span class="hljs-literal">false</span>)<br>    &#125;<br>  &#125;, [propsOnOk])<br><br>  useImperativeHandle(ref, <span class="hljs-function">() =&gt;</span> &#123;<br>    <span class="hljs-keyword">return</span> &#123;<br>      open<br>    &#125;<br>  &#125;, [open])<br><br>  <span class="hljs-keyword">return</span> (<br>    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Modal</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">visible</span>=<span class="hljs-string">&#123;visible&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">onCancel</span>=<span class="hljs-string">&#123;onCancel&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">onOk</span>=<span class="hljs-string">&#123;onOk&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      <span class="hljs-attr">title</span>=<span class="hljs-string">&#x27;自定义modal&#x27;</span></span></span><br><span class="hljs-tag"><span class="xml">    &gt;</span></span><br><span class="xml">      hello world </span><br><span class="xml">    <span class="hljs-tag">&lt;/<span class="hljs-name">Modal</span>&gt;</span></span><br>  )<br><br>&#125;)<br><br><span class="hljs-comment">// parent </span><br><span class="hljs-keyword">const</span> ParentComponent = <span class="hljs-function">() =&gt;</span> &#123;<br><br>  <span class="hljs-keyword">const</span> modalRef = useRef(<span class="hljs-literal">null</span>)<br><br>  <span class="hljs-keyword">return</span> (<br>    <span class="xml"><span class="hljs-tag">&lt;&gt;</span></span><br><span class="xml">      <span class="hljs-tag">&lt;<span class="hljs-name">Button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">&#123;()</span> =&gt;</span> &#123;</span><br><span class="xml">        modalRef.current?.open()</span><br><span class="xml">      &#125;&#125;&gt;open<span class="hljs-tag">&lt;/<span class="hljs-name">Button</span>&gt;</span></span><br><span class="xml">      <span class="hljs-tag">&lt;<span class="hljs-name">InternalVisibleModal</span></span></span><br><span class="hljs-tag"><span class="xml">        <span class="hljs-attr">ref</span>=<span class="hljs-string">&#123;modalRef&#125;</span></span></span><br><span class="hljs-tag"><span class="xml">      /&gt;</span></span><br><span class="xml">    <span class="hljs-tag">&lt;/&gt;</span></span><br>  )<br><br>&#125;<br></code></pre></td></tr></table></figure>






<h3 id="html2canvas"><a href="#html2canvas" class="headerlink" title="html2canvas"></a>html2canvas</h3><ul>
<li>配合<a target="_blank" rel="noopener" href="https://github.com/niklasvh/html2canvas">html2canvas</a>   </li>
<li><code>html</code>转<code>图片</code>  <h4 id="typescript-1"><a href="#typescript-1" class="headerlink" title="typescript"></a>typescript</h4><figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><code class="hljs ts"><span class="hljs-keyword">import</span> html2canvas, &#123; Options &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;html2canvas&#x27;</span>;<br><br><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">captureCover</span>(<span class="hljs-params"></span></span><br><span class="hljs-params"><span class="hljs-function">  query: <span class="hljs-built_in">string</span>,</span></span><br><span class="hljs-params"><span class="hljs-function">  html2canvasOptions: Partial&lt;Options&gt; = &#123;&#125;,</span></span><br><span class="hljs-params"><span class="hljs-function"></span>) </span>&#123;<br>  <span class="hljs-keyword">const</span> element: HTMLElement | <span class="hljs-literal">null</span> = <span class="hljs-built_in">document</span>.querySelector(query);<br><br>  <span class="hljs-keyword">if</span> (!element) <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject();<br><br>  <span class="hljs-keyword">const</span> &#123; width, height &#125; = element.getBoundingClientRect() || &#123;&#125;;<br><br>  <span class="hljs-keyword">const</span> options: Partial&lt;Options&gt; = &#123;<br>    <span class="hljs-attr">useCORS</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">allowTaint</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">logging</span>: <span class="hljs-literal">true</span>,<br>    width,<br>    height,<br>    <span class="hljs-attr">scrollY</span>: <span class="hljs-number">0</span>,<br>    <span class="hljs-attr">scrollX</span>: <span class="hljs-number">0</span>,<br>    <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">&#x27;rgba(0, 0, 0, 0)&#x27;</span>,<br>    ...html2canvasOptions,<br>  &#125;;<br><br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>&lt;Blob&gt;(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> &#123;<br>    html2canvas(element <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>, options).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">context</span>) </span>&#123;<br>      context.toBlob(<br>        <span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> &#123;<br>          <span class="hljs-keyword">if</span> (data) &#123;<br>            resolve(data);<br>          &#125; <span class="hljs-keyword">else</span> &#123;<br>            reject();<br>          &#125;<br>        &#125;,<br>        <span class="hljs-string">&#x27;image/png&#x27;</span>,<br>        <span class="hljs-number">0.9</span>,<br>      );<br>    &#125;);<br>  &#125;);<br>&#125;<br><br></code></pre></td></tr></table></figure>
<h4 id="javascript-1"><a href="#javascript-1" class="headerlink" title="javascript"></a>javascript</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">import</span> html2canvas <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;html2canvas&#x27;</span>;<br><br><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">captureCover</span>(<span class="hljs-params"></span></span><br><span class="hljs-params"><span class="hljs-function">  query,</span></span><br><span class="hljs-params"><span class="hljs-function">  html2canvasOptions</span></span><br><span class="hljs-params"><span class="hljs-function"></span>) </span>&#123;<br>  <span class="hljs-keyword">const</span> element = <span class="hljs-built_in">document</span>.querySelector(query);<br><br>  <span class="hljs-keyword">if</span> (!element) <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject();<br><br>  <span class="hljs-keyword">const</span> &#123; width, height &#125; = element.getBoundingClientRect() || &#123;&#125;;<br><br>  <span class="hljs-keyword">const</span> options = &#123;<br>    <span class="hljs-attr">useCORS</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">allowTaint</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">logging</span>: <span class="hljs-literal">true</span>,<br>    width,<br>    height,<br>    <span class="hljs-attr">scrollY</span>: <span class="hljs-number">0</span>,<br>    <span class="hljs-attr">scrollX</span>: <span class="hljs-number">0</span>,<br>    <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">&#x27;rgba(0, 0, 0, 0)&#x27;</span>,<br>    ...html2canvasOptions,<br>  &#125;;<br><br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> &#123;<br>    html2canvas(element, options).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">context</span>) </span>&#123;<br>      context.toBlob(<br>        <span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> &#123;<br>          <span class="hljs-keyword">if</span> (data) &#123;<br>            resolve(data);<br>          &#125; <span class="hljs-keyword">else</span> &#123;<br>            reject();<br>          &#125;<br>        &#125;,<br>        <span class="hljs-string">&#x27;image/png&#x27;</span>,<br>        <span class="hljs-number">0.9</span>,<br>      );<br>    &#125;);<br>  &#125;);<br>&#125;<br></code></pre></td></tr></table></figure>


</li>
</ul>
<h3 id="jspdf"><a href="#jspdf" class="headerlink" title="jspdf"></a>jspdf</h3><ul>
<li>配合<a target="_blank" rel="noopener" href="https://github.com/niklasvh/html2canvas">html2canvas</a>  </li>
<li><code>html</code>转<code>pdf</code>  <h4 id="typescript-2"><a href="#typescript-2" class="headerlink" title="typescript"></a>typescript</h4><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-keyword">import</span> jsPDF <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;jspdf&#x27;</span><br><span class="hljs-keyword">import</span> html2Canvas, &#123; Options &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;html2canvas&#x27;</span><br><br><span class="hljs-keyword">const</span> A4_RATIO = <span class="hljs-number">630</span> / <span class="hljs-number">891</span><br><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> html2Pdf = <span class="hljs-keyword">async</span> (query: <span class="hljs-built_in">string</span>, <span class="hljs-attr">canvasOpts</span>: Partial&lt;Options&gt;=&#123;&#125;) =&gt; &#123;<br><br>  <span class="hljs-keyword">const</span> element: HTMLElement | <span class="hljs-literal">null</span> = <span class="hljs-built_in">document</span>.querySelector(query)<br><br>  <span class="hljs-keyword">if</span>(!element) <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject()<br><br>  <span class="hljs-keyword">const</span> originWidth = element.offsetWidth<br>  <span class="hljs-keyword">const</span> originHeight = element.offsetHeight<br><br>  <span class="hljs-keyword">const</span> scale = <span class="hljs-number">595.28</span> / originWidth<br>  <span class="hljs-keyword">const</span> scaleCanvas = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&#x27;canvas&#x27;</span>)<br>  scaleCanvas.width = <span class="hljs-number">595.28</span><br>  scaleCanvas.height = originHeight * scale <br><br>  <span class="hljs-keyword">var</span> opts: Partial&lt;Options&gt; = &#123;<br>    <span class="hljs-attr">useCORS</span>: <span class="hljs-literal">true</span>,<span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">allowTaint</span>: <span class="hljs-literal">true</span>,<span class="hljs-comment">//允许跨域图片</span><br>    <span class="hljs-attr">logging</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-attr">width</span>: originWidth, <br>    <span class="hljs-attr">height</span>: originHeight,<br>    <span class="hljs-attr">scrollY</span>: <span class="hljs-number">0</span>, <br>    <span class="hljs-attr">scrollX</span>: <span class="hljs-number">0</span>,<br>    <span class="hljs-attr">canvas</span>: scaleCanvas,<br>    scale,<br>    <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">&quot;rgba(0, 0, 0, 0)&quot;</span>,<br>    <span class="hljs-attr">onclone</span>: <span class="hljs-function">(<span class="hljs-params"><span class="hljs-built_in">document</span></span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">const</span> deleteStyleKeys = [<span class="hljs-string">&#x27;transform&#x27;</span>, <span class="hljs-string">&#x27;transition&#x27;</span>, <span class="hljs-string">&#x27;boxShadow&#x27;</span>]<br>      <span class="hljs-keyword">const</span> element: HTMLElement | <span class="hljs-literal">null</span> = <span class="hljs-built_in">document</span>.querySelector(query)<br>      <span class="hljs-keyword">if</span>(!element) <span class="hljs-keyword">return</span> <br>      deleteStyleKeys.forEach(<span class="hljs-function">(<span class="hljs-params">key</span>) =&gt;</span> ((element.style <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>)[key] = <span class="hljs-string">&#x27;&#x27;</span>))<br>    &#125;,<br>    ...canvasOpts<br>  &#125;;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> &#123;<br>    html2Canvas(element, opts).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">context</span>) </span>&#123;<br>  <br>      <span class="hljs-keyword">let</span> contentWidth = context.width <br>      <span class="hljs-keyword">let</span> contentHeight = context.height   <br>      <span class="hljs-keyword">let</span> pageHeight = contentWidth / A4_RATIO  <br>      <span class="hljs-keyword">let</span> leftHeight = contentHeight <br>      <span class="hljs-keyword">let</span> position = <span class="hljs-number">0</span><br>  <br>      <span class="hljs-keyword">let</span> pageData = context.toDataURL(<span class="hljs-string">&#x27;image/png&#x27;</span>, <span class="hljs-number">0.9</span>)<br>      <br>      <span class="hljs-keyword">let</span> PDF = <span class="hljs-keyword">new</span> jsPDF(<span class="hljs-string">&#x27;&#x27;</span>, <span class="hljs-string">&#x27;pt&#x27;</span>, <span class="hljs-string">&#x27;a4&#x27;</span>)<br>      <span class="hljs-keyword">if</span> (leftHeight &lt;= pageHeight) &#123;<br>        PDF.addImage(pageData, <span class="hljs-string">&#x27;PNG&#x27;</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, contentWidth, contentHeight)<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        <span class="hljs-keyword">while</span> (leftHeight &gt;= <span class="hljs-number">20</span>) &#123;<br>          PDF.addImage(pageData, <span class="hljs-string">&#x27;PNG&#x27;</span>, <span class="hljs-number">0</span>, position, contentWidth, contentHeight)<br>          leftHeight -= pageHeight<br>          position -= pageHeight<br>          <span class="hljs-keyword">if</span> (leftHeight &gt;= <span class="hljs-number">20</span>) &#123;<br>            PDF.addPage()<br>          &#125;<br>        &#125;<br>      &#125;<br><br>      resolve(PDF.output(<span class="hljs-string">&#x27;blob&#x27;</span>))<br>      <br>    &#125;)<br>  &#125;)<br>&#125;<br></code></pre></td></tr></table></figure>

</li>
</ul>
<h3 id="SuperPartial"><a href="#SuperPartial" class="headerlink" title="SuperPartial"></a>SuperPartial</h3><ul>
<li><code>typescript</code></li>
<li><code>Partial</code> 深层次版本  <h4 id="typescript-3"><a href="#typescript-3" class="headerlink" title="typescript"></a>typescript</h4><figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs ts"><span class="hljs-keyword">type</span> SuperPartial&lt;T&gt; = &#123;<br>  [K <span class="hljs-keyword">in</span> keyof T]?: SuperPartial&lt;T[K]&gt;<br>&#125;<br></code></pre></td></tr></table></figure>

</li>
</ul>
<h3 id="withTry"><a href="#withTry" class="headerlink" title="withTry"></a>withTry</h3><ul>
<li>工具方法  </li>
<li>异步错误捕获  <h4 id="typescript-4"><a href="#typescript-4" class="headerlink" title="typescript"></a>typescript</h4><figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withTry</span>&lt;<span class="hljs-title">T</span>=<span class="hljs-title">any</span>&gt; (<span class="hljs-params">func: <span class="hljs-built_in">Function</span></span>) </span>&#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">...args: <span class="hljs-built_in">any</span>[]</span>): <span class="hljs-title">Promise</span>&lt;[<span class="hljs-title">any</span>, <span class="hljs-title">T</span> | <span class="hljs-title">null</span>]&gt; </span>&#123;<br>    <span class="hljs-keyword">try</span> &#123;<br>      <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> func(...args)<br>      <span class="hljs-keyword">return</span> [<span class="hljs-literal">null</span>, data]<br>    &#125;<span class="hljs-keyword">catch</span>(err) &#123;<br>      <span class="hljs-keyword">return</span> [err, <span class="hljs-literal">null</span>]<br>    &#125;<br>  &#125;<br>&#125;<br></code></pre></td></tr></table></figure>
<h4 id="javascript-2"><a href="#javascript-2" class="headerlink" title="javascript"></a>javascript</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withTry</span> (<span class="hljs-params">func</span>) </span>&#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">...args</span>) </span>&#123;<br>    <span class="hljs-keyword">try</span> &#123;<br>      <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> func(...args)<br>      <span class="hljs-keyword">return</span> [<span class="hljs-literal">null</span>, data]<br>    &#125;<span class="hljs-keyword">catch</span>(err) &#123;<br>      <span class="hljs-keyword">return</span> [err, <span class="hljs-literal">null</span>]<br>    &#125;<br>  &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

</li>
</ul>
<h3 id="sleep"><a href="#sleep" class="headerlink" title="sleep"></a>sleep</h3><ul>
<li>延迟方法  <h4 id="javascript-3"><a href="#javascript-3" class="headerlink" title="javascript"></a>javascript</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sleep</span>(<span class="hljs-params">time=<span class="hljs-number">1000</span></span>) </span>&#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-params">resolve</span> =&gt;</span> <span class="hljs-built_in">setTimeout</span>(resolve, time))<br>&#125;<br></code></pre></td></tr></table></figure>


</li>
</ul>
<h2 id="结束"><a href="#结束" class="headerlink" title="结束"></a>结束</h2><p>到这里结束，希望对各位有帮助。  </p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E5%89%8D%E7%AB%AF/">前端</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/fragment-code/">fragment code</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/03/02/%E5%AD%97%E5%8F%B7%E4%B8%8E%E5%83%8F%E7%B4%A0%E7%9A%84%E5%AF%B9%E5%BA%94%E5%80%BC/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">字号与像素的对应值</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/11/24/%E6%96%87%E4%BB%B6%E5%88%86%E7%89%87%E4%B8%8A%E4%BC%A0/">
                        <span class="hidden-mobile">文件分片上传</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <div style="font-size: 0.85rem"> <span id="timeDate">载入天数...</span> <span id="times">载入时分秒...</span> <script src="/js/duration.js"></script> <script src="/js/code-viewer.js"></script> </div> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


<!-- hexo injector body_end start -->
  <script src="//cdn.jsdelivr.net/gh/bynotes/texiao/source/js/xiantiao.js"></script>
  <script src="//cdn.jsdelivr.net/gh/bynotes/texiao/source/js/xiaoxingxing.js"></script>
  <script src="//cdn.jsdelivr.net/gh/bynotes/texiao/source/js/dianjichuzi.js"></script>
<!-- hexo injector body_end end --><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"right","width":150,"height":300,"mobile":{"show":true}},"log":false});</script></body>
</html>
